package net.sunofbeach.blog.controller.portal;


import net.sunofbeach.blog.response.ResponseResult;
import net.sunofbeach.blog.services.INavigationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/portal/navigation")
public class NavigationPortalApi {


    @Autowired
    private INavigationService navigationService;

    @GetMapping("/list/{page}/{size}")
    public ResponseResult listNavigations(@PathVariable("page") int page,
                                       @PathVariable("size") int size,
                                       @RequestParam(value = "state",required = false)String state,
                                       @RequestParam(value = "keyword",required = false) String keyword,
                                       @RequestParam(value = "categoryId" ,required = false) String categoryId
    ) {
        return navigationService.listNavigations(page,size,keyword,categoryId,state);
    }

    @GetMapping("/top/{navigationState}")
    public ResponseResult getNavigationByState(@PathVariable("navigationState") String navigationState) {
        return navigationService.getNavigationByState(navigationState);
    }


    @GetMapping("/{navigationId}")
    public ResponseResult getNavigationById(@PathVariable("navigationId") String navigationId) {
        return navigationService.getNavigationById(navigationId);
    }
}
